package com.aspose.cells;

class zawh extends zawe {
   private zagu[][] g;
   private int h;
   private int[] i;
   private boolean j;
   private int k;
   private boolean l;
   private int m;
   private int n;
   private boolean o;
   private boolean p;
   private int q;
   private int r;
   private zagu s;
   private int t;
   private int u;

   public zawh(zagu[][] var1, int var2, int var3, int[] var4, int var5, int var6, zagu var7, int var8, int var9, boolean var10, boolean var11, int var12) {
      super(var6, var7, var8, var9, var10, var11);
      this.g = var1;
      this.h = var5;
      this.l = this.h < 2;
      this.i = var4;
      this.j = var4 != null;
      this.k = var12;
      this.m = var2;
      this.n = var3;
      this.E();
   }

   zawh(zawh var1) {
      super(var1.b, var1.a, var1.e, var1.f, var1.c, var1.d);
      this.g = var1.g;
      this.h = var1.h;
      this.i = var1.i;
      this.j = var1.j;
      this.k = var1.k;
      this.l = var1.l;
      this.m = var1.m;
      this.n = var1.n;
      this.o = var1.o;
      this.p = var1.p;
      this.q = var1.q;
      this.r = var1.r;
      this.s = var1.s;
      this.t = var1.t;
      this.u = var1.u;
   }

   public zahn b(zaay var1) {
      return new zawh(this);
   }

   public int c() {
      return this.h;
   }

   public int d() {
      return 1;
   }

   public int e() {
      return this.h;
   }

   public boolean l() {
      return this.l;
   }

   public boolean m() {
      return this.l;
   }

   public boolean n() {
      return true;
   }

   public zagu a(int var1, int var2) {
      if (this.l) {
         return this.s;
      } else if (this.p) {
         return this.a;
      } else {
         var1 += this.m;
         if (var1 >= this.q && var1 <= this.r) {
            if (this.q == this.r) {
               return this.s;
            }

            zagu[] var3 = this.g[var1];
            if (var3 != null) {
               var2 += this.n;
               if (this.j && var1 < this.i.length) {
                  var2 -= this.i[var1];
               }

               if (var2 > -1 && var2 < var3.length) {
                  return var3[var2];
               }
            }
         }

         return this.a;
      }
   }

   public void f() {
      if (!this.l && !this.p) {
         this.t = this.q - 1;
      }
   }

   public boolean b(int var1, int var2) {
      if (!this.l && !this.p) {
         var1 += this.m;
         if (var1 <= this.q) {
            if (this.o) {
               this.t = this.q;
               return true;
            }

            if (this.t == this.q) {
               return true;
            }

            this.t = this.q - 1;
         } else {
            if (var1 == this.t && this.t <= this.r) {
               return true;
            }

            this.t = var1 - 1;
         }

         return this.g();
      } else {
         return false;
      }
   }

   public boolean a(int var1) {
      return this.b(var1, 0);
   }

   public boolean g() {
      if (!this.l && !this.p) {
         ++this.t;
         if (this.t <= this.r) {
            if (this.q == this.r) {
               return true;
            } else {
               zagu[] var1 = this.g[this.t];
               if (var1 != null) {
                  if (this.j) {
                     if (this.t < this.i.length) {
                        this.u = this.n - this.i[this.t];
                     } else {
                        this.u = this.n;
                     }
                  }

                  if (this.u > -1 && this.u < var1.length) {
                     this.s = var1[this.u];
                     if (!a(this.s, this.a)) {
                        return true;
                     }
                  }
               }

               while(true) {
                  ++this.t;
                  if (this.t > this.r) {
                     return false;
                  }

                  var1 = this.g[this.t];
                  if (var1 != null) {
                     if (this.j) {
                        if (this.t < this.i.length) {
                           this.u = this.n - this.i[this.t];
                        } else {
                           this.u = this.n;
                        }
                     }

                     if (this.u > -1 && this.u < var1.length) {
                        this.s = var1[this.u];
                        if (!a(this.s, this.a)) {
                           return true;
                        }
                     }
                  }
               }
            }
         } else {
            return false;
         }
      } else {
         return false;
      }
   }

   public zagu h() {
      if (this.s.b() == 13) {
         zzh var1 = (zzh)this.s;
         if (var1.k().c() == 2) {
            this.s = var1.k().n();
            this.g[this.t][this.u] = this.s;
         }
      }

      return this.s;
   }

   public int i() {
      return this.t - this.m;
   }

   public int j() {
      return 0;
   }

   public int k() {
      return this.t - this.m;
   }

   public zahn b(int var1) {
      return this.l ? new zaya(this.s) : new zaya(this.a(var1, 0));
   }

   public zahn c(int var1) {
      return this;
   }

   public boolean a(zagu var1) {
      return a(var1, this.l ? this.s : this.a);
   }

   public void a(zaay var1) {
      if (this.c && var1.g != this.e) {
         this.m += var1.g - this.e;
         this.e = var1.g;
         if (this.d && var1.h != this.f) {
            this.n += var1.h - this.f;
            this.f = var1.h;
         }

         this.E();
      } else if (this.d && var1.h != this.f) {
         this.n += var1.h - this.f;
         this.f = var1.h;
         this.E();
      }

   }

   public boolean q() {
      return this.o;
   }

   public int r() {
      if (!this.o) {
         this.C();
      }

      return this.p ? -1 : this.q - this.m;
   }

   public int s() {
      if (!this.o) {
         this.C();
      }

      return this.p ? -1 : this.r - this.m;
   }

   public int t() {
      if (!this.o) {
         this.C();
      }

      return this.p ? -1 : 0;
   }

   public int u() {
      if (!this.o) {
         this.C();
      }

      return this.p ? -1 : 0;
   }

   public int v() {
      if (!this.o) {
         this.C();
      }

      return this.p ? -1 : this.q - this.m;
   }

   public int w() {
      if (!this.o) {
         this.C();
      }

      return this.p ? -1 : this.r - this.m;
   }

   public boolean a(zaay var1, int[] var2) {
      if (!this.c && !this.d) {
         if (!this.o) {
            this.C();
         }

         if (this.p) {
            return false;
         } else {
            var2[0] = this.q - this.m;
            var2[1] = 0;
            var2[2] = this.r - this.m;
            var2[3] = 0;
            return true;
         }
      } else {
         int var3;
         int var4;
         if (this.c) {
            var3 = this.m + var1.l.StartRow - this.e;
            var4 = var1.l.e() + this.h - 1;
         } else {
            var3 = this.m;
            var4 = this.h;
         }

         int var5;
         int var6;
         if (this.d) {
            var5 = this.n + var1.l.StartColumn - this.f;
            var6 = var1.l.f();
         } else {
            var5 = this.n;
            var6 = 1;
         }

         return zawi.a(this.g, var3, var5, this.i, var4, var6, this.a, var2);
      }
   }

   public boolean b(zaay var1, int[] var2) {
      if (!this.c && !this.d) {
         if (!this.o) {
            this.C();
         }

         if (this.r < 0) {
            return false;
         } else {
            var2[0] = this.q - this.m;
            var2[1] = this.r - this.m;
            return true;
         }
      } else {
         int[] var3 = new int[4];
         int var4;
         int var5;
         if (this.c) {
            var4 = this.m + var1.l.StartRow - this.e;
            var5 = var1.l.e() + this.h - 1;
         } else {
            var4 = this.m;
            var5 = this.h;
         }

         int var6;
         int var7;
         if (this.d) {
            var6 = this.n + var1.l.StartColumn - this.f;
            var7 = var1.l.f();
         } else {
            var6 = this.n;
            var7 = 1;
         }

         if (zawi.a(this.g, var4, var6, this.i, var5, var7, this.a, var3)) {
            var2[0] = var3[0] * var7 + var3[1];
            var2[1] = var3[2] * var7 + var3[3];
            return true;
         } else {
            return false;
         }
      }
   }

   private void C() {
      this.o = true;
      int var1 = this.n;

      while(true) {
         zagu[] var2 = this.g[this.q];
         if (var2 != null) {
            if (this.j) {
               if (this.q < this.i.length) {
                  var1 = this.n - this.i[this.q];
               } else {
                  var1 = this.n;
               }
            }

            if (var1 > -1 && var1 < var2.length && !a(var2[var1], this.a)) {
               if (this.r > this.q) {
                  do {
                     var2 = this.g[this.r];
                     if (var2 != null) {
                        if (this.j) {
                           if (this.r < this.i.length) {
                              var1 = this.n - this.i[this.r];
                           } else {
                              var1 = this.n;
                           }
                        }

                        if (var1 > -1 && var1 < var2.length && !a(var2[var1], this.a)) {
                           return;
                        }
                     }

                     --this.r;
                  } while(this.r != this.q);

                  if (this.j) {
                     if (this.q < this.i.length) {
                        var1 = this.n - this.i[this.q];
                     } else {
                        var1 = this.n;
                     }
                  }

                  this.s = this.g[this.q][var1];
                  break;
               }

               this.s = var2[var1];
               break;
            }
         }

         ++this.q;
         if (this.q > this.r) {
            this.D();
            break;
         }
      }

   }

   private void D() {
      this.p = true;
      this.q = -1;
      this.r = -1;
   }

   private void E() {
      this.t = this.m - 1;
      this.u = this.n;
      this.o = false;
      this.p = false;
      if (this.m < this.g.length && this.n < this.k && this.m > -this.h && this.n >= 0) {
         if (!this.l && this.m != this.g.length - 1) {
            if (this.m + this.h == 1) {
               this.t = 0;
            }
         } else {
            this.t = this.m;
         }

         if (this.t >= this.m) {
            this.o = true;
            if (this.j && this.t < this.i.length) {
               this.u -= this.i[this.t];
            }

            if (this.u >= 0 && this.u < this.g[this.t].length) {
               if (this.l) {
                  this.D();
                  this.s = this.g[this.t][this.u];
               } else {
                  this.s = this.g[this.t][this.u];
                  if (a(this.s, this.a)) {
                     this.D();
                  } else {
                     this.q = this.t;
                     this.r = this.t;
                  }
               }
            } else {
               this.D();
            }
         } else {
            this.o = false;
            this.q = Math.max(0, this.m);
            this.r = Math.min(this.m + this.h, this.g.length) - 1;
         }
      } else {
         this.o = true;
         this.D();
      }

   }
}
